(function() {
  var BASE_PATH, DEBUG_MODE, fs, indexData;

  DEBUG_MODE = true;

  BASE_PATH = 'http://localhost:10000/';

  fs = require('fs');

  indexData = {};

  fs.readFile("./data/articles.json", 'utf8', function(err, data) {
    var trim;
    if (err) {
      console.log(err);
      return;
    }
    trim = /[\n\r\t]/g;
    return indexData.articlesData = JSON.parse(data.replace(trim, ''));
  });

  module.exports = {
    index: function(req, res) {
      return res.render('index', {
        basePath: BASE_PATH,
        title: '每天再往前一点！',
        debug: DEBUG_MODE,
        cssFileArr: [],
        jsFileArr: [],
        pageData: {
          articles: indexData.articlesData
        }
      });
    },
    base: function(req, res) {
      return res.render('base', {
        basePath: BASE_PATH,
        title: '每天再多写一点！',
        debug: DEBUG_MODE,
        cssFileArr: [],
        jsFileArr: []
      });
    },
    article: function(req, res) {
      return res.render('article', {
        basePath: BASE_PATH,
        title: '每天再多看一点！',
        debug: DEBUG_MODE,
        pageData: indexData.articlesData[req.params.id || 0],
        cssFileArr: [],
        jsFileArr: []
      });
    }
  };

}).call(this);
